package com.benmei.ntlive.dto.ntmsg.cons;

/**
 * Created by Peter on 2017/11/21.
 * 学生；2 老师
 */
public enum ClientRole {

    STUDENT(1, "student"),

    TEACHER(2, "teacher");

    private final int value;

    private final String name;


    ClientRole(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    public static boolean validate(String name) {
        boolean result = false;
        for (ClientRole role : ClientRole.values()) {
            if (role.getName().equals(name)) {
                result = true;
                break;
            }
        }
        return result;
    }

    public static ClientRole getByValue(int value) {
        for (ClientRole role : ClientRole.values()) {
            if (role.getValue() == value) {
                return role;
            }
        }
        return null;
    }

    public static ClientRole getByName(String name) {
        for (ClientRole role : ClientRole.values()) {
            if (role.name == name) {
                return role;
            }
        }
        return null;
    }


}

